package com.worklikedance.customcontrols;

import com.worklikedance.priceonline.R;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class TabButton extends RelativeLayout {

	private Button mButton = null;
	private TextView mFromSourceTextView = null;
	private View mLineView = null;
	
	public TabButton(Context context) {
		super(context);		
	}
	
	public TabButton(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);        
    }

    public TabButton(Context context, AttributeSet attrs) {
        super(context, attrs);        
    }
    
    @Override
    protected void onFinishInflate() {
    	super.onFinishInflate();
    	
    	mButton = (Button)findViewById(R.id.button);
    	mFromSourceTextView = (TextView)findViewById(R.id.fromSourceTextView);
    	mLineView = findViewById(R.id.lineView);
    }
    
    public void setTitleSource(String title, int icon, String source) {
		mButton.setText(title);
		mButton.setCompoundDrawablesWithIntrinsicBounds(icon, 0, 0, 0);
		mFromSourceTextView.setText(source);
	}
    
    @Override
    public void setEnabled(boolean enabled) {
    	super.setEnabled(enabled);
    	
    	mButton.setEnabled(enabled);
    	mLineView.setVisibility(enabled? View.INVISIBLE : View.VISIBLE); 
    }
}
